package com.androidx.p013lv.mine.activity;

import android.view.View;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.ViewPager;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.UserAccount;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.model.UserInfoModel;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.TimeUtils;
import com.androidx.p013lv.base.view.CircleImageView;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.databinding.ActivityVipCenterLayoutBinding;
import com.androidx.p013lv.mine.dialog.FastDialogUtils;
import com.androidx.p013lv.mine.fragment.GoldCardFragment;
import com.androidx.p013lv.mine.fragment.TicketsFragment;
import com.androidx.p013lv.mine.fragment.VipCardFragment;
import com.androidx.p013lv.mine.model.VipCenterModel;
import com.gyf.immersionbar.ImmersionBar;

/* renamed from: com.androidx.lv.mine.activity.VipCenterActivity */
public class VipCenterActivity extends BaseActivity<ActivityVipCenterLayoutBinding> {
    public String backTitle;
    private VipCenterModel model;
    public int source;
    public int type;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityVipCenterLayoutBinding) this.binding).toolbar).statusBarDarkFont(false).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_vip_center_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.model = (VipCenterModel) new ViewModelProvider(this).get(VipCenterModel.class);
        ((ActivityVipCenterLayoutBinding) this.binding).setType(Integer.valueOf(this.type));
        ((ActivityVipCenterLayoutBinding) this.binding).setBackTitle(this.backTitle);
        ((ActivityVipCenterLayoutBinding) this.binding).setClick(new OnClick());
        ((ActivityVipCenterLayoutBinding) this.binding).viewPager.setAdapter(new Adapter(getSupportFragmentManager()));
        ((ActivityVipCenterLayoutBinding) this.binding).tabLayout.setupWithViewPager(((ActivityVipCenterLayoutBinding) this.binding).viewPager);
        ((ActivityVipCenterLayoutBinding) this.binding).viewPager.setCurrentItem(this.type);
        ((ActivityVipCenterLayoutBinding) this.binding).viewPager.setOffscreenPageLimit(3);
        ((ActivityVipCenterLayoutBinding) this.binding).viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            /* class com.androidx.p013lv.mine.activity.VipCenterActivity.C12731 */

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageScrollStateChanged(int i) {
            }

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageScrolled(int i, float f, int i2) {
            }

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageSelected(int i) {
                VipCenterActivity.this.type = i;
                ((ActivityVipCenterLayoutBinding) VipCenterActivity.this.binding).setType(Integer.valueOf(VipCenterActivity.this.type));
            }
        });
        this.model.dataUserAccount().observe(this, new Observer<UserAccount>() {
            /* class com.androidx.p013lv.mine.activity.VipCenterActivity.C12742 */

            public void onChanged(UserAccount userAccount) {
                ((ActivityVipCenterLayoutBinding) VipCenterActivity.this.binding).setUserAccount(userAccount);
            }
        });
        ((UserInfoModel) new ViewModelProvider(this).get(UserInfoModel.class)).data().observe(this, new Observer<BaseRes<UserInfo>>() {
            /* class com.androidx.p013lv.mine.activity.VipCenterActivity.C12753 */

            public void onChanged(BaseRes<UserInfo> baseRes) {
                if (baseRes.getCode() == 200) {
                    UserInfo data = baseRes.getData();
                    SpUtils.getInstance().setUserInfo(data);
                    ((ActivityVipCenterLayoutBinding) VipCenterActivity.this.binding).setUserInfo(data);
                }
            }
        });
        this.model.getCardList(this);
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initData() {
        super.initData();
        UserInfo userInfo = SpUtils.getInstance().getUserInfo();
        UserAccount userAccount = SpUtils.getInstance().getUserAccount();
        ((ActivityVipCenterLayoutBinding) this.binding).setUserInfo(userInfo);
        ((ActivityVipCenterLayoutBinding) this.binding).setUserAccount(userAccount);
        ((ActivityVipCenterLayoutBinding) this.binding).mo14327c(SpUtils.getInstance().getString("domain") + userInfo.getLogo());
    }

    public static void loadImgUserHead(CircleImageView circleImageView, String str) {
        GlideUtils.loadPicHead(str, circleImageView);
    }

    public static void setUserVipData(TextView textView, UserInfo userInfo) {
        String str;
        if (userInfo.getFreeWatches() == -1) {
            str = "視頻vip: " + TimeUtils.utcToChinaTwo(userInfo.getExpiredVip());
        } else {
            str = "您當前還未開通視頻VIP哦";
        }
        textView.setText(str);
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        VipCenterModel vipCenterModel = this.model;
        if (vipCenterModel != null) {
            vipCenterModel.cancelHttp();
        }
        super.onDestroy();
    }

    /* renamed from: com.androidx.lv.mine.activity.VipCenterActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            VipCenterActivity.this.finish();
        }

        public void btnService() {
            FastDialogUtils instance = FastDialogUtils.getInstance();
            VipCenterActivity vipCenterActivity = VipCenterActivity.this;
            instance.createServicePopupWindow(vipCenterActivity, ((ActivityVipCenterLayoutBinding) vipCenterActivity.binding).ivRightMenu, "充值記錄", "兌換會員", new View.OnClickListener() {
                /* class com.androidx.p013lv.mine.activity.VipCenterActivity.OnClick.View$OnClickListenerC12761 */

                public void onClick(View view) {
                    ARouter.getInstance().build(Constance.BUY_HISTORY_ACTIVITY).navigation();
                }
            }, new View.OnClickListener() {
                /* class com.androidx.p013lv.mine.activity.VipCenterActivity.OnClick.View$OnClickListenerC12772 */

                public void onClick(View view) {
                    ARouter.getInstance().build(Constance.EXCHANGE_CENTER_ACTIVITY).navigation();
                }
            });
        }
    }

    /* renamed from: com.androidx.lv.mine.activity.VipCenterActivity$Adapter */
    public class Adapter extends FragmentStatePagerAdapter {
        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return 3;
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return i == 0 ? "開通VIP" : i == 1 ? "購買金幣" : "購買門票";
        }

        Adapter(FragmentManager fragmentManager) {
            super(fragmentManager, 1);
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            if (i == 0) {
                return VipCardFragment.newInstance(VipCenterActivity.this.source);
            }
            if (i == 1) {
                return GoldCardFragment.newInstance(VipCenterActivity.this.source);
            }
            return TicketsFragment.newInstance(VipCenterActivity.this.source);
        }
    }
}
